package com.yunji.app.product;

import com.yunji.common.base.BaseController;
import com.yunji.common.base.response.Response;
import com.yunji.common.base.response.ResponseHelper;
import com.yunji.product.business.ProductBusiness;
import com.yunji.product.domain.ProductDO;
import com.yunji.product.domain.ProductTypeDO;
import com.yunji.cabinet.dto.CapacityCeilingDTO;
import com.yunji.product.params.ProductBindParam;
import com.yunji.product.params.ProductParam;
import com.yunji.product.params.ProductTypeParam;
import com.yunji.product.service.IProductService;
import com.yunji.product.service.IProductTypeService;
import com.yunji.product.vo.ProductBindVO;
import com.yunji.product.vo.ProductVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Package com.yunji.web.product
 * FileName:	GateWayProductController.java
 * Copyright:	Copyright © 2024 云集互联 All Rights Reserved
 * Company:		云集互联
 * @version: 1.0
 * @since: JDK 1.8.0_202
 * Create at:   2024-04-08 09:31:06
 * Description:
 * 用户端商品交互
 * Modification History:
 * Author					Date						Version			Description
 * --------------------------------------------------------------------------------
 * HuaAo				2024-04-08 09:31:06			1.0				1.0 Version
 */
@Api(tags = "移动端-商品模块")
@RestController
@RequestMapping("/gateway/product")
public class GateWayProductController extends BaseController {
    @Resource
    ProductBusiness business;

    @Resource
    private IProductService productService;

    @Resource
    private IProductTypeService productTypeService;

    /**
     * 查询商品信息列表
     */
    @ApiOperation("查询商品列表")
    @GetMapping("/productList")
    public Response<List<ProductVO>> list(ProductParam param) {
        List<ProductVO> list = business.cabinetProduct(param);
        return ResponseHelper.success(list);
    }

    /**
     * 查询商品类型列表
     */
    @ApiOperation("查询商品类型列表")
    @GetMapping("/productTypeList")
    public Response<List<ProductTypeDO>> search(ProductTypeParam param) {
        List<ProductTypeDO> list = productTypeService.search(param);
        return ResponseHelper.success(list);
    }

    /**
     * 获取商品信息详细信息
     */
    @ApiOperation("获取商品信息详细信息")
    @GetMapping(value = "/queryById")
    public Response<ProductDO> getInfo(@RequestParam("id") Long id, @RequestParam("qrcode") String qrcode) {
        return ResponseHelper.success(business.select(id, qrcode));
    }

    @ApiOperation("员工获取商品列表")
    @GetMapping("/getProductList")
    public  Response<List<ProductBindVO>> getProductList(ProductBindParam param) {
        return ResponseHelper.success(business.getProductList(param));
    }

}
